function radius = estimate_R(img,img_R)
%ESTIMATE_R 输入圆点目标物拍摄图,估计可视半径
figure()
imshow(img,[]);
img = imbinarize(img);
hTxt = text(15,15,'估计圆的可视半径','FontWeight','bold','Color','y');
Rmin = floor(img_R);
Rmax = ceil(img_R+20);
[center, radius] = imfindcircles(img,[Rmin Rmax],'Sensitivity',0.94,'EdgeThreshold',1e-2);
% Display the circle
viscircles(center,radius)
% Display the calculated center
hold on;
plot(center(:,1),center(:,2),'yx','LineWidth',2);
hold off;
delete(hTxt);
message = sprintf('可视半径为 %2.1f 像素', radius);
text(15,15,message,'Color','y','FontWeight','bold');
pause(2)
close;
end

